import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { defHttp } from '/@/utils/http/axios';
//列表数据
export const columns : BasicColumn[] = [
	/* {
		title: '状态',
		align: "center",
		dataIndex: 'stats',
		customRender: ({ text }) => {
			if (text == ) return '已删除'
			return '使用中'
		}
	}, */
	{
		title: '城市',
		align: "center",
		dataIndex: 'cityid_dictText'
	},
	{
		title: '显示样式',
		align: "center",
		dataIndex: 'showstyle',
		customRender: ({ text }) => {
			if (text == 'weekly') return '两横排滚动'
			if (text == 'festival') return '卡片'
			if (text == 'days') return '竖排列表'
			if (text == 'Sudoku') return '九宫格'
		}
	},
	{
		title: '标题',
		align: "center",
		dataIndex: 'title'
	},
	/* 	{
			title: '产品/行程',
			align: "center",
			dataIndex: 'ids_dictText',
			customRender: ({ text, record }) => {
				if (record.type == 'Group') {
					console.log()
					let o = JSON.parse(record.ids_dictText)
					return o.mainTitle 
				} else {
					return record.pids_dictText
				}
			}
		}, */
	{
		title: '说明',
		align: "center",
		dataIndex: 'msg'
	},
	{
		title: '栏目/类别',
		align: "center",
		dataIndex: 'type',
		customRender:({text})=>{
			if(text=='Type')return '类别'
			if(text=='Column')return '栏目'
		}
	},
	{
		title: '排序',
		align: "center",
		dataIndex: 'sort'
	},
];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: '栏目/类别',
		field: 'type',
		component: 'JDictSelectTag',
		componentProps: {
			//dictCode: 'week_activity_type'
			options: [
				{ label: '栏目', value: 'Column' },
				{ label: '类别', value: 'Type' }
			]
		},
	},
	{
		label: '城市',
		field: 'cityid',
		component: 'ApiSelect',
		componentProps: ({ formActionType, formModel }) => {
			return {
				//multiple: 多选；不填写为单选
				mode: '',
				//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
				api: () => defHttp.get({ url: '/coupleUser/getCitysByTenantId' }),
				//数值转成String
				numberToString: false,
				//标题字段
				labelField: 'name',
				//值字段
				valueField: 'id',
				//请求参数
				params: {
				},
				//返回结果字段
				resultField: 'records'
			}

		},

	},

];
//表单数据
export const formSchema : FormSchema[] = [
	/*  {
		label: '是否删除：true 删除  false 正常',
		field: 'stats',
		component: 'Input',
		dynamicRules: ({model,schema}) => {
			  return [
					 { required: true, message: '请输入是否删除：true 删除  false 正常!'},
			  ];
		 },
	  }, */
	{
		label: '城市',
		field: 'cityid',
		component: 'ApiSelect',
		componentProps: ({ formActionType, formModel }) => {
			return {
				//multiple: 多选；不填写为单选
				mode: '',
				//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
				api: () => defHttp.get({ url: '/coupleUser/getCitysByTenantId' }),
				//数值转成String
				numberToString: false,
				//标题字段
				labelField: 'name',
				//值字段
				valueField: 'id',
				//请求参数
				params: {
				},
				//返回结果字段
				resultField: 'records'
			}

		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择城市!' },
			];
		},
	},

	/* {
		label: '板块',
		field: 'items',
		component: 'Input',
		slot: 'selectStyle'
	},*/
	{
		label: '显示样式',
		field: 'showstyle',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "index_page_style"
		},
	},
	{
		label: '标题',
		field: 'title',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入标题!' },
			];
		},
	},
	{
		label: '说明',
		field: 'msg',
		component: 'Input',
		show: ({ values }) => {
			return values.type == 'Column'
		}
	},
	{
		label: '排序',
		field: 'sort',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入排序!' },
			];
		},
	},
	{
		label: '显示类型',
		field: 'typeTwo',
		component: 'JDictSelectTag',
		componentProps: {
			//dictCode: 'week_activity_type'
			options: [
				{ label: '产品', value: 'Product' },
				{ label: '常规大团', value: 'Group' }
			]
		},
		show: ({ values }) => {
			return values.type == 'Column'
		}
	},
	{
		label: '产品',
		field: 'pdtIds',
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: 'couple_shop_pdt,title,id',
			acync: true
		},
		show: ({ values }) => {
			return values.typeTwo == 'Product' && values.type == 'Column'
		}
	},
	{
		label: '选择行程',
		field: 'travelIds',
		component: 'ApiSelect',
		componentProps: ({ formActionType, formModel }) => {
			return {
				//multiple: 多选；不填写为单选
				mode: 'multiple',
				//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
				api: () => defHttp.get({ url: '/activity/bsCityHomeStyle/getGroupList' }),
				//数值转成String
				numberToString: false,
				//标题字段
				labelField: 'title',
				//值字段
				valueField: 'id',
				//请求参数
				params: {
				},
				//返回结果字段
				resultField: 'records'
			}

		},
		show: ({ values }) => {
			return values.typeTwo == 'Group' && values.type == 'Column'
		},

	},


	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '',
		field: 'type',
		component: 'Input',
		show: false
	},
];
export const styleColumns : BasicColumn[] = [
	{
		title: '显示样式',
		align: "center",
		edit: true,
		editComponent: 'Select',
		editComponentProps: {
			options: [
				{
					label: '九宫格',
					value: 'Sudoku',
				},
				{
					label: '竖排列表',
					value: 'days',
				},
				{
					label: '卡片',
					value: 'festival',
				},
				{
					label: '两横排滚动',
					value: 'weekly',
				},
			],
		},
		dataIndex: 'showstyle'
	},
	{
		title: '标题',
		align: "center",
		dataIndex: 'title',
		edit: true,
		editComponent: 'Input',
	},
	{
		title: '说明',
		align: "center",
		dataIndex: 'msg',
		edit: true,
		editComponent: 'Input',
	},
	{
		title: '排序',
		align: "center",
		dataIndex: 'sort',
		edit: true,
		editComponent: 'InputNumber',
	},
];

export const pdtColumns : BasicColumn[] = [
	{
		title: '是否删除',
		align: "center",
		dataIndex: 'stats'
	},
	{
		title: '样式id',
		align: "center",
		dataIndex: 'styleid'
	},
	/* 	{
			title: 'itemId',
			align: "center",
			dataIndex: 'travelid'
		}, */
	/* 	{
			title: '产品：Product 行程：Group',
			align: "center",
			dataIndex: 'type',
			customRender:({text})=>{
				if(text=='Group')return '常规行程'
				if(text=='Product')return '商品'
			}
		}, */
	{
		title: 'createtime',
		align: "center",
		dataIndex: 'createtime'
	},
];

export const travelColumns : BasicColumn[] = [
	{
		title: '是否删除',
		align: "center",
		dataIndex: 'stats'
	},
	{
		title: '样式id',
		align: "center",
		dataIndex: 'styleid'
	},
	/* 	{
			title: 'itemId',
			align: "center",
			dataIndex: 'travelid'
		}, */
	/* 	{
			title: '产品：Product 行程：Group',
			align: "center",
			dataIndex: 'type'
		}, */
	{
		title: 'createtime',
		align: "center",
		dataIndex: 'createtime'
	},
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}